//    Copyright (C) Kherty.  All rights reserved.

using System;

namespace OpenLS.Spreadsheet
{
    partial class Worksheet
    {
        #region Nested type: Utilities

        private class Utilities
        {
            public static Predicate<CellAddress> GetGreaterThanPredicate<T>(int index) where T : Dimension
            {
                if (typeof (T) == typeof (Column))
                    return address => address.Column > index;

                return address => address.Row > index;
            }

            public static Predicate<CellAddress> GetGreaterThanOrEqualPredicate<T>(int index) where T : Dimension
            {
                if (typeof (T) == typeof (Column))
                    return address => address.Column >= index;

                return address => address.Row >= index;
            }

            public static void AddCellInColumns(Cell cell)
            {
                if (cell.ColumnSpan == 1)
                    cell.Column.Add(cell);
                else
                    foreach (Column col in cell.GetColumns())
                        col.Add(cell);
            }

            public static void AddCellInRows(Cell cell)
            {
                if (cell.RowSpan == 1)
                    cell.Row.Add(cell);
                else
                    foreach (Row row in cell.GetRows())
                        row.Add(cell);
            }
        }

        #endregion
    }
}